package com.ies.dx.dex.file;

import java.io.DataInputStream;

import com.ies.dx.util.Input;

public class encoded_value extends dex_item
{
    public final static int VALUE_BYTE = 0x00;  
    public final static int VALUE_SHORT = 0x02;  
    public final static int VALUE_CHAR = 0x03;  
    public final static int VALUE_INT = 0x04;  
    public final static int VALUE_LONG = 0x06; 
    public final static int VALUE_FLOAT = 0x10;  
    public final static int VALUE_DOUBLE = 0x11;  
    public final static int VALUE_STRING = 0x17;  
    public final static int VALUE_TYPE = 0x18;   
    public final static int VALUE_FIELD = 0x19;  
    public final static int VALUE_METHOD = 0x1a;   
    public final static int VALUE_ENUM = 0x1b;  
    public final static int VALUE_ARRAY = 0x1c;  
    public final static int VALUE_ANNOTATION = 0x1d;  
    public final static int VALUE_NULL = 0x1e; 
    public final static int VALUE_BOOLEAN = 0x1f;  

    private int value_arg;
    private int value_type;
    private int byte_size;
    private byte[] value;
    
    private encoded_array array;
    private encoded_annotation annotation;
    
    public encoded_value(dex_file file)
    {
        super(file);
    }
    
    public void read(Input dis)
    {
        try
        {
            int b = dis.readUnsignedByte();
            value_type = b & 0x0000001f;
            value_arg = (b & 0x000000e0) >> 5;
            
            switch (value_type)
            {
                case VALUE_BYTE:
                    value = new byte[1];
                    dis.read(value);
                    break;
                case VALUE_SHORT:            
                case VALUE_CHAR:
                case VALUE_INT:
                case VALUE_FLOAT:
                case VALUE_STRING:
                case VALUE_TYPE:
                case VALUE_FIELD:
                case VALUE_METHOD:
                case VALUE_ENUM:
                case VALUE_LONG:
                case VALUE_DOUBLE:
                    value = new byte[value_arg + 1];
                    dis.read(value);
                    break;
                case VALUE_ARRAY:
                    array = new encoded_array(mFile);
                    array.read(dis);
                    break;
                case VALUE_ANNOTATION:
                    annotation = new encoded_annotation(mFile);
                    break;
                case VALUE_NULL:
                case VALUE_BOOLEAN:
                    
                    break;     
            }

        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

    public void show()
    {

        
    }

    public String getData()
    {

        return null;
    }

    @Override
    public void readData(Input dis)
    {
        // TODO Auto-generated method stub
        
    }
    
}
